package io.afu.baseframework.annotations.impls;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author RffanLAB.方露宇
 * @version 0.1
 */
@Order(-1)
@Aspect
@Component
public class DesensitizationImpl {

    private static Logger logger = LoggerFactory.getLogger(DesensitizationImpl.class);

    private final String expResult = "******";

    @Pointcut(value = "@annotation(io.afu.baseframework.annotations.Desensitization)")
    public void cutDesensitization(){

    }

    @Around("cutDesensitization()")
    public Object desensitizationImpl(ProceedingJoinPoint point) throws Throwable {
        Object result = point.proceed();
        Object[] args = point.getArgs();
        for (Object arg : args) {
            if (arg instanceof String) {
                String str = (String) arg;
                logger.info("原始字符串:{}", str);
            }
        }
        return result;
    }


    @AfterReturning(value = "cutDesensitization()", returning = "keys")
    public void afterReturning(JoinPoint joinPoint, Object keys) throws Throwable {
        logger.info("afterReturning:{}", keys);
    }



}
